// Sample Query
var getData = function () {
  var fetchXML = '' + 
    '<fetch top="10">' +
    '    <entity name="account">' +
    '        <attribute name="primarycontactid" />' +
    '        <attribute name="lastusedincampaign" />' +
    '        <attribute name="telephone1" />' +
    '        <attribute name="name" />' +
    '        <attribute name="accountid" />' +
    '        <order attribute="name" descending="false" />' +
    '        <filter type="and">' +
    '            <condition attribute="statecode" operator="eq" value="0" />' +
    '        </filter>' +
    '        <link-entity name="contact" from="parentcustomerid" to="accountid" alias="ab">' +
    '            <attribute name="fullname" />' +
    '            <filter type="and">' +
    '                <condition attribute="firstname" operator="like" value="A%" />' +
    '                <condition attribute="lastname" operator="eq" value="Smith" />' +
    '            </filter>' +
    '        </link-entity>' +
    '    </entity>' +
    '</fetch>';

  JCL.fetch(fetchXML, processData);
};

// Sample Fake 
var getFakeData = function () {
  var fake = [{"guid":"0d04cc52-f6ee-e211-9fa2-005056b800f8","logicalName":"contact","attributes":{"yomifullname":{"type":"c:string","value":"Paul Way"},"contactid":{"type":"c:guid","value":"0d04cc52-f6ee-e211-9fa2-005056b800f8"}}}];
  processData(fake);
};

// Sample Call 
var processData = function (data) {
  // handling data
  alert('Found ' + data.length + ' record(s).');

  // or something like...
  alert('Found ' + data[0].attributes.yomifullname.value);
};

// Sample Usage 
if (typeof Xrm === 'object') {
  getData();
} else { 
  getFakeData();
}